package com.sunhy.accountserver.controller;

import com.alipay.sofa.runtime.api.annotation.SofaReference;
import com.sunhy.accountserver.entity.vo.BillVO;
import com.sunhy.accountserver.facade.BillService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/bill")
public class BillController {

    @SofaReference
    private BillService billService;

    @RequestMapping(value = "/initTransfer")
    public String initiateTransfer(@RequestBody BillVO billVO) {
        Long integer = billService.initiateTransfer(billVO.getFromUserId(), billVO.getToUserId(), billVO.getAmountStr());
        return integer + "";
    }

    @RequestMapping(value = "/confirmTransfer")
    public String confirmTransfer(@RequestParam("billId") Long billId) {
        return billService.confirmTransfer(billId);
    }


}
